package model

/**
 * do_balance json参数解析结构体
 *
room_type类型
1，2，3，4 真金
5，6，7，8 积分

1:真金 （points）
5：积分（points）
{
	"wins":11,
	"uids":[1,2,3],
	"room_type":5,
	"op":0,   //0 1 2   0减 1加 2结算
	"cash_num":22
	"lose_uids":[
		{
			"uid":11
			"score":11
		}
	]
}

room_type 1和5 (points算分)
	uids下
	op=0进场扣cash_num * 80
	op=1加cash_num * 80
	op=2结算
		lose_uids
		lose积分或现金余额 += cash_num*score
		num = cash_num*80 - cash_num*score
		如果 num>0 wins+=num * 80% ,最后 wins += cash_num * 80

room_type 其它：
	wins积分或余额 += cash_num * len(uids) * 80%

 *
*/

type Op int

const Op_Dim = 0    //减
const Op_Plus = 1   //加
const Op_Settle = 2 //结算
const Op_Tied = 3   //平局

/**
 * 0真金 1积分
 */
var RoomTypeGameType = map[int]string{
	1: "cash",
	2: "cash",
	3: "cash",
	4: "cash",
	5: "score",
	6: "score",
	7: "score",
	8: "score",
}

const (
	Fee       float64 = 0.8
	PointsMax float64 = 80 //points最多输多少
)

type LostUidS struct {
	Uid   int64   `json:"uid"`
	Score float64 `json:"score"`
}

type BalanceRequest struct {
	Wins         int64      `json:"wins"`
	UidS         []int64    `json:"uids"`
	RoomType     int        `json:"room_type"`
	RoomId       string     `json:"room_id"`
	Op           int        `json:"op"` //0 1 2   0减 1加 2结算
	CashNumInt64 int64      `json:"cash_num_int64"`
	CashNum      float64    `json:"cash_num"`
	LoseUidS     []LostUidS `json:"lose_uids"`
}

/**
 * get_balance json解析结构体
 */
type GetUserBalance struct {
	Uid []int64 `json:"uid"`
}

type UserBalance struct {
	Id      int64 `xorm:"id" json:"-"`
	Uid     int64 `xorm:"uid" json:"uid"`
	Cash    int64 `xorm:"cash" json:"cash"`   //现金
	Score   int64 `xorm:"score" json:"score"` //积分
	Created int64 `xorm:"created" json:"-"`
	Updated int64 `xorm:"updated" json:"-"`
}

/**
 *
`id` bigint(11) NOT NULL AUTO_INCREMENT,
 `from_id` int(11) NOT NULL DEFAULT '1' COMMENT '来源1游戏服',
 `uid` bigint(11) NOT NULL DEFAULT '0' COMMENT '用户uid',
 `room_id` int(11) NOT NULL DEFAULT '0' COMMENT '房间id',
 `room_type` int(11) NOT NULL DEFAULT '0' COMMENT '房间类型',
 `op` int(11) NOT NULL DEFAULT '0' COMMENT '操作类型',
 `value` int(11) NOT NULL DEFAULT '0' COMMENT '结算值',
 `created` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
 `updated` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间'
*/
type UserBalanceLog struct {
	Id        int64  `xorm:"id"`
	FromId    int    `xorm:"from_id"`
	Uid       int64  `xorm:"uid"`       //uid
	RoomId    string `xorm:"room_id"`   //房间room_id
	RoomType  int    `xorm:"room_type"` //房间类型
	Op        int    `xorm:"op"`        //操作值
	Value     int64  `xorm:"value"`
	LosePrize int64  `xorm:"lose_prize"`
	Fee       int64  `xorm:"fee"`  //收取费用
	Desc      string `xorm:"desc"` //描述
	Created   int64  `xorm:"created"`
	Updated   int64  `xorm:"updated"`
}

/**
 * 余额操作请求日志
 */
type UserBalanceRequest struct {
	Id       int64  `xorm:"id"`
	FromId   int    `xorm:"from_id"`
	RoomId   string `xorm:"room_id"`
	RoomType int    `xorm:"room_type"`
	Op       int    `xorm:"op"`
	CashNum  string `xorm:"cash_num"`
	Data     string `xorm:"data"`
	Created  int64  `xorm:"created"`
	Updated  int64  `xorm:"updated"`
}
